import time

from crawler.connection import filter_push_redis, redis_conn, redis_shedana

a = {
    "women": [
        {
            "ACCESSORIES": [
                {
                    "Bag Accessories": "https://www.ssense.com/en-hk/women/bag-accessories"
                },
                {
                    "Belts & Suspenders": "https://www.ssense.com/en-hk/women/belts-suspenders"
                },
                {
                    "Cosmetic Cases": "https://www.ssense.com/en-hk/women/cosmetic-cases"
                },
                {
                    "Eyewear": "https://www.ssense.com/en-hk/women/eyewear"
                },
                {
                    "Face Masks": "https://www.ssense.com/en-hk/women/face-masks"
                },
                {
                    "Fine Jewelry": "https://www.ssense.com/en-hk/women/fine-jewelry"
                },
                {
                    "Gloves": "https://www.ssense.com/en-hk/women/gloves"
                },
                {
                    "Hats": "https://www.ssense.com/en-hk/women/hats"
                },
                {
                    "Jewelry": "https://www.ssense.com/en-hk/women/jewelry"
                },
                {
                    "Keychains": "https://www.ssense.com/en-hk/women/keychains"
                },
                {
                    "Scarves": "https://www.ssense.com/en-hk/women/scarves"
                },
                {
                    "Socks": "https://www.ssense.com/en-hk/women/socks"
                },
                {
                    "Tech": "https://www.ssense.com/en-hk/women/tech"
                },
                {
                    "Umbrellas": "https://www.ssense.com/en-hk/women/umbrellas"
                },
                {
                    "Wallets & Card Holders": "https://www.ssense.com/en-hk/women/wallets-card-holders"
                },
                {
                    "Watches": "https://www.ssense.com/en-hk/women/watches"
                }
            ],
            "BAGS": [
                {
                    "Backpacks": "https://www.ssense.com/en-hk/women/backpacks"
                },
                {
                    "Clutches & Pouches": "https://www.ssense.com/en-hk/women/clutches-pouches"
                },
                {
                    "Duffle & Top Handle Bags": "https://www.ssense.com/en-hk/women/duffle-top-handle-bags"
                },
                {
                    "Messenger Bags & Satchels": "https://www.ssense.com/en-hk/women/messenger-bags-satchels"
                },
                {
                    "Shoulder Bags": "https://www.ssense.com/en-hk/women/shoulder-bags"
                },
                {
                    "Tote Bags": "https://www.ssense.com/en-hk/women/tote-bags"
                },
                {
                    "Travel Bags": "https://www.ssense.com/en-hk/women/travel-bags"
                }
            ],
            "CLOTHING": [
                {
                    "Activewear": "https://www.ssense.com/en-hk/women/activewear"
                },
                {
                    "Dresses": "https://www.ssense.com/en-hk/women/dresses"
                },
                {
                    "Jackets & Coats": "https://www.ssense.com/en-hk/women/jackets-coats"
                },
                {
                    "Jeans": "https://www.ssense.com/en-hk/women/jeans"
                },
                {
                    "Jumpsuits": "https://www.ssense.com/en-hk/women/jumpsuits"
                },
                {
                    "Lingerie": "https://www.ssense.com/en-hk/women/lingerie"
                },
                {
                    "Pants": "https://www.ssense.com/en-hk/women/pants"
                },
                {
                    "Shorts": "https://www.ssense.com/en-hk/women/shorts"
                },
                {
                    "Skirts": "https://www.ssense.com/en-hk/women/skirts"
                },
                {
                    "Sweaters": "https://www.ssense.com/en-hk/women/sweaters"
                },
                {
                    "Swimwear": "https://www.ssense.com/en-hk/women/swimwear"
                },
                {
                    "Tops": "https://www.ssense.com/en-hk/women/tops"
                }
            ],
            "SHOES": [
                {
                    "Boots": "https://www.ssense.com/en-hk/women/boots"
                },
                {
                    "Flats": "https://www.ssense.com/en-hk/women/flats"
                },
                {
                    "Heels": "https://www.ssense.com/en-hk/women/heels"
                },
                {
                    "Sandals": "https://www.ssense.com/en-hk/women/sandals"
                },
                {
                    "Sneakers": "https://www.ssense.com/en-hk/women/sneakers"
                }
            ]
        }
    ],
    "men": [
        {
            "ACCESSORIES": [
                {
                    "Belts & Suspenders": "https://www.ssense.com/en-hk/men/belts-suspenders"
                },
                {
                    "Eyewear": "https://www.ssense.com/en-hk/men/eyewear"
                },
                {
                    "Face Masks": "https://www.ssense.com/en-hk/men/face-masks"
                },
                {
                    "Gloves": "https://www.ssense.com/en-hk/men/gloves"
                },
                {
                    "Hats": "https://www.ssense.com/en-hk/men/hats"
                },
                {
                    "Jewelry": "https://www.ssense.com/en-hk/men/jewelry"
                },
                {
                    "Keychains": "https://www.ssense.com/en-hk/men/keychains"
                },
                {
                    "Pocket Squares & Tie Bars": "https://www.ssense.com/en-hk/men/pocket-squares-tie-bars"
                },
                {
                    "Scarves": "https://www.ssense.com/en-hk/men/scarves"
                },
                {
                    "Socks": "https://www.ssense.com/en-hk/men/socks"
                },
                {
                    "Tech": "https://www.ssense.com/en-hk/men/tech"
                },
                {
                    "Ties": "https://www.ssense.com/en-hk/men/ties"
                },
                {
                    "Umbrellas": "https://www.ssense.com/en-hk/men/umbrellas"
                },
                {
                    "Wallets & Card Holders": "https://www.ssense.com/en-hk/men/wallets-card-holders"
                },
                {
                    "Watches": "https://www.ssense.com/en-hk/men/watches"
                }
            ],
            "BAGS": [
                {
                    "Backpacks": "https://www.ssense.com/en-hk/men/backpacks"
                },
                {
                    "Briefcases": "https://www.ssense.com/en-hk/men/briefcases"
                },
                {
                    "Duffle Bags": "https://www.ssense.com/en-hk/men/duffle-bags"
                },
                {
                    "Messenger Bags": "https://www.ssense.com/en-hk/men/messenger-bags"
                },
                {
                    "Pouches & Document Holders": "https://www.ssense.com/en-hk/men/pouches-document-holders"
                },
                {
                    "Tote Bags": "https://www.ssense.com/en-hk/men/tote-bags"
                },
                {
                    "Travel Bags": "https://www.ssense.com/en-hk/men/travel-bags"
                }
            ],
            "CLOTHING": [
                {
                    "Jackets & Coats": "https://www.ssense.com/en-hk/men/jackets-coats"
                },
                {
                    "Jeans": "https://www.ssense.com/en-hk/men/jeans"
                },
                {
                    "Pants": "https://www.ssense.com/en-hk/men/pants"
                },
                {
                    "Shirts": "https://www.ssense.com/en-hk/men/shirts"
                },
                {
                    "Shorts": "https://www.ssense.com/en-hk/men/shorts"
                },
                {
                    "Suits & Blazers": "https://www.ssense.com/en-hk/men/suits-blazers"
                },
                {
                    "Sweaters": "https://www.ssense.com/en-hk/men/sweaters"
                },
                {
                    "Swimwear": "https://www.ssense.com/en-hk/men/swimwear"
                },
                {
                    "Tops": "https://www.ssense.com/en-hk/men/tops"
                },
                {
                    "Underwear & Loungewear": "https://www.ssense.com/en-hk/men/underwear-loungewear"
                }
            ],
            "SHOES": [
                {
                    "Boat Shoes & Moccasins": "https://www.ssense.com/en-hk/men/boat-shoes-moccassins/en-hk/men/boots"
                },
                {
                    "Boots": "https://www.ssense.com/en-hk/men/espadrilles"
                },
                {
                    "Espadrilles": "https://www.ssense.com/en-hk/men/lace-ups-oxfords"
                },
                {
                    "Lace Ups & Oxfords": "https://www.ssense.com/en-hk/men/monkstraps"
                },
                {
                    "Monkstraps": "https://www.ssense.com/en-hk/men/sandals"
                },
                {
                    "Sandals": "https://www.ssense.com/en-hk/men/slippers-loafers"
                },
                {
                    "Slippers & Loafers": "https://www.ssense.com/en-hk/men/sneakers"
                }
            ]
        }
    ]

}
url_list = list()
for k, v in a.items():
    sex = k
    for i in v:
        for c, d in i.items():
            for g in d:
                for b, f in g.items():
                    item = dict()
                    category = c + '>>' + b
                    url = f
                    item['category'] = category
                    item['url'] = url
                    item['sex'] = sex
                    url_list.append(item)
for u in url_list:
    u['category'] = u['category'].split('>>')[0].capitalize() + '>>' + u['category'].split('>>')[1]

for index, url in enumerate(url_list):
    task = {
        "jobId": index,
        'info': url,
        'domain': 'ssense'.upper(),
        'filename': 'main',
        'types': 'electronic_business',
        "scheduleTime": int(time.time() * 1000),
        "triggerChannel": 'SONIC_SPIDER',
    }
    result = filter_push_redis(redis_shedana, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
    # result = filter_push_redis(redis_conn, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
    print(result)
    input()
